package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author mycp 推荐攻略
 */
@Setter @Getter
@JsonIgnoreProperties("handler")
public class StrategyDetail extends BaseDomain {

    public static final Integer STATE_RELEASE = 0; //发布
    public static final Integer STATE_TEMP = 1; //草稿

    private String title;// 标题

    private Date createTime;// 创建时间

    private Date releaseTime;// 发布时间

    private Integer sequence;// 序号

    private StrategyCatalog strategyCatalog;// 分类攻略

    private String coverUrl;// 封面

    private Integer state = STATE_TEMP;// 状态, 默认为草稿状态

    private StrategyContent strategyContent;// 推荐攻略内容

    /**
     * 编辑页面回显使用
     */
    private Long strategyId;
    private Long strategyCatalogId;

    public String getStateName(){
        String stateName = "草稿";
        if (STATE_RELEASE.equals(state)){
            stateName = "发布";
        }
        return stateName;
    }

    public String getJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id", getId());
        map.put("title", title);
        map.put("sequence", sequence);
        map.put("strategyCatalog", strategyCatalog);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        map.put("strategyId", strategyId);
        return JSONUtil.toJSONString(map);
    }
}